<!DOCTYPE html>
<#assign ctx=springMacroRequestContext.contextPath />
<html>
<head>
    <meta charset="UTF-8">
    <title>调度系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx}/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/css/login.css" media="all">
    <link rel="shortcut icon" href="${ctx}/images/favicon.ico"/>

    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="prefetch" ></link>
</head>
<body class="login-bg">
<div class="layui-container layui-anim layui-anim-upbit">
    <div class="admin-login-background">
        <div class="layui-form login-form">
            <form class="layui-form" action="">
                <div class="layui-form-item logo-title">
                    <h1>调度系统登录</h1>
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username"></label>
                    <input type="text" name="username" lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-password"></label>
                    <input type="password" name="password" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-vercode"></label>
                    <input type="text" name="verityCode" lay-verify="required" placeholder="图形验证码" autocomplete="off" class="layui-input verification captcha">
                    <div class="captcha-img">
                        <a href="javascript:;">
                            <img id="captchaPic" onclick="this.src=this.src+'?c='+Math.random();" src="${ctx}/user/getVerityCode" />
                        </a>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="login">登 入</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="${ctx}/lib/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        // 进行登录操作
        form.on('submit(login)', function (data) {
            //设置遮罩层
            var loading = layer.msg('登录中', {icon: 16, shade: 0.3, time:0});
            $.ajax({
                type: 'post',
                url: '${ctx}/user/auth',
                data: data.field,
                dataType: 'json',
                success: function(res) {
                    layer.close(loading);
                    if (res.status == 200) {
                        window.open('${ctx}/index', '_self');
                    } else {
                        // 重新获取验证码
                        $('#captchaPic').trigger("click");
                        //提示框
                        layer.msg(res.message, {
                            icon : 5,
                            offset : "auto",
                            time : 1500
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>